package com.loby.data.mapper;

import com.loby.data.base.pojo.TBaseOrganization;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface OrganizationMapper {
    @Select("select * from t_base_organization where pk_id =#{id}")
    TBaseOrganization getOrganizationById(@Param("id") long id);

    /**
     * 插入组织机构并同步至Zookeeper
     * @param baseOrganization 组织机构
     * @return 组织机构id
     */
    @Insert("INSERT INTO t_base_organization VALUES (#{pkId},#{pkOrgCode},#{orgName},#{regAddr},#{phoneticIndex},#{legalPerson},#{legalPersonId},#{fkAdministrativeDivisionCode},#{fkIndustrialClassCode},#{fkDitRegTypeNo},#{postalCode},#{establishmentDate},#{bussinessScope},#{operatingPeriod},#{linkMan},#{linkManPhone},#{fkDitCorpStateNo})")
    int insertOrganization(TBaseOrganization baseOrganization);

    /**
     * 根据主键id删除组织机构并同步zookeeper
     * @param id 组织机构id
     * @return
     */
    @Delete("delete  from t_base_organization where pk_id=#{id}")
    int removeOrganization(@Param("id") long id);

    /**
     * 根据主键id修改组织机构数据
     * @param
     * @return
     */
    @Update("UPDATE t_base_organization set pk_org_code=#{pkOrgCode},org_name=#{orgName},phonetic_index=#{phoneticIndex} where pk_id=#{pkId}")
    int updateOrganization(TBaseOrganization baseOrganization);


    @Select("select * from t_base_organization where fk_administrative_division_code=#{code}")
    List<TBaseOrganization> getOrganizationByAdministrativeDivisionCode(@Param("code") String code);






}
